package com.school.fuyuan.business.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@Controller
public class PageController {

    @RequestMapping(value = "/login")
    public String login(Model model) {
        return "login.html";
    }

    @RequestMapping(value = "/checkUser")
    public void checkUser(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.sendRedirect("redirect:info/infoManage/index");
    }

    @RequestMapping(value = "/index")
    public String index(Model model,HttpServletRequest request) {
        String userId = (String)request.getParameter("id");
        model.addAttribute("userId", userId);
        return "index.html";
    }

    @RequestMapping(value = "/welcome")
    public String welcome(Model model) {
        return "welcome.html";
    }

    @RequestMapping(value = "/listInfoManage")
    public String listInfoManage(Model model) {
        return "infoManage-list.html";
    }

    @RequestMapping(value = "/addInfoManage")
    public String addInfoManage(Model model) {
        return "infoManage-add.html";
    }

    @RequestMapping(value = "/editInfoManage/{id}")
    public String editInfoManage(Model model,@PathVariable long id) {
        model.addAttribute("id", id);
        return "infoManage-add.html";
    }

    @RequestMapping(value = "/uploadInfoManage")
    public String uploadInfoManage(Model model) {
        return "infoManage-upload.html";
    }

    @RequestMapping(value = "/exportInfoManage")
    public String exportInfoManage(Model model) {
        return "infoManage-export.html";
    }

    @RequestMapping(value = "/followInfoManage/{id}/{followUserId}")
    public String followInfoManage(Model model,@PathVariable long id,@PathVariable long followUserId) {
        model.addAttribute("id", id);
        model.addAttribute("followUserId", followUserId);
        return "infoManage-follow.html";
    }

    @RequestMapping(value = "/remindInfoManage")
    public String remindInfoManage(Model model) {
        return "infoManage-remind.html";
    }

    @RequestMapping(value = "/listRole")
    public String listRole(Model model) {
        return "admin-role.html";
    }

    @RequestMapping(value = "/addRole")
    public String addRole(Model model) {
        return "admin-role-add.html";
    }

    @RequestMapping(value = "/listAdmin")
    public String listAdmin(Model model) {
        return "admin-list.html";
    }

    @RequestMapping(value = "/addAdmin")
    public String addAdmin(Model model) {
        return "admin-add.html";
    }

    @RequestMapping(value = "/editAdmin/{userId}")
    public String editAdmin(Model model,@PathVariable long userId) {
        model.addAttribute("userId", userId);
        return "admin-add.html";
    }

    @RequestMapping(value = "/editPasswordAdmin")
    public String editPasswordAdmin(Model model) {
        return "admin-password.html";
    }

}